/*
 * @Author: chunlai
 * @Date: 2025-03-19 16:52:02
 * @LastEditTime: 2025-03-19 17:15:33
 * @LastEditors: minsheng_insurance_agency_zhoucl
 * @FilePath: \0.newInsure\src\methods\occup.js
 * @Description: 保司特殊规则配置
 */
import { createResult } from "@/translate/validate/customer.js";
import { userAge } from "@/methods/globals.js";
const zhiyeRules = {
  changcheng: (userInfo) => {
    const { occupationCode, birthDate, sex } = userInfo;
    const ageValue = userAge(birthDate),
      sexValue = sex;
    const childCode = "95757"; // 学龄前儿童
    const housewifeCode = "96232"; // 家庭主妇
    if (ageValue >= 6 && [childCode].includes(occupationCode)) {
      return createResult(
        false,
        `年龄大于等于6周岁，职业不能为学龄前儿童`,
        "occupationCode"
      );
    }
    if (ageValue < 6 && ![childCode].includes(occupationCode)) {
      return createResult(
        false,
        `年龄小于等于5周岁，职业只能是学龄前儿童`,
        "occupationCode"
      );
    }
    if (sexValue === "0" && [housewifeCode].includes(occupationCode)) {
      return createResult(false, `男性，职业不能为家庭主妇`, "occupationCode");
    }
    if (ageValue < 16 && [housewifeCode].includes(occupationCode)) {
      return createResult(
        false,
        `年龄小于16周岁，职业不能为家庭主妇`,
        "occupationCode"
      );
    }
  },
  hezhong: (userInfo) => {
    const { occupationCode, birthDate, sex } = userInfo;
    const ageValue = userAge(birthDate),
      sexValue = sex;
    const childCode = "114450"; // 学龄前儿童
    const studentCode = "114130"; // 学生
    if (ageValue < 6 && occupationCode !== childCode) {
      return createResult(
        false,
        `年龄0-5周岁（含），职业只能是“学龄前儿童”`,
        "occupationCode"
      );
    }
    if (
      ageValue >= 6 &&
      ageValue <= 7 &&
      ![childCode, studentCode].includes(occupationCode)
    ) {
      return createResult(
        false,
        `年龄6-7周（含），职业只能是“学生（军警校除外）（17周岁以下）或 学龄前儿童”`,
        "occupationCode"
      );
    }
    if (ageValue >= 8 && ageValue <= 14 && occupationCode !== studentCode) {
      return createResult(
        false,
        `年龄8-14周（含），职业只能是“学生（军警校除外）（17周岁以下）”`,
        "occupationCode"
      );
    }
    if (
      ageValue >= 15 &&
      ageValue <= 17 &&
      [childCode, "114131"].includes(occupationCode)
    ) {
      return createResult(
        false,
        `15-17周岁（含），职业不能为“学龄前儿童, 学生（军警校除外）（18周岁以上）”`,
        "occupationCode"
      );
    }
  },
};

export default {
  zhiyeRules,
};
